export default function debounce (func, delay) {
  let timer = null
  const that = this
  return function (...args) {
    if (timer) clearTimeout(timer)
    timer = setTimeout(() => {
      console.log(...args)
      // 执行srcoll对象的函数,里面的this必须为与原来的this,
      // 所以需要用apply保持原来的this
      func.apply(that, args)
    }, delay)
  }
}
